package copiaClase8;

import java.awt.*;

import javax.swing.JPanel;

@SuppressWarnings("serial")
public class ClaPanCol extends JPanel {
	private int iRad, iIncre = 40;
	private Color cRec;
	public static int X=0;
	public static int Y=0;
	public static int Vx=5;
	public static int Vy=5;
	public static int diam=30; 
	
	
	public ClaPanCol() {
		
		setSize(500, 500);
		setBackground(Color.cyan);
		
	}
	
	public void paintComponent(Graphics2D g){
		super.paintComponent(g);
		Graphics2D gra2D = (Graphics2D)g; //formato de grafic a 2d		
		gra2D.setColor(Color.RED);//color del grafico
		gra2D.fillOval(X,Y,diam,diam);//coordenadas y ancho y alto fill=lleno
	}
public void moverBolita(){		
		
		if (X >=  this.getWidth() - diam )
			Vx=Vx*-1;
		
		if (X<0)
			Vx=Vx*-1;
		
		if (Y >= this.getHeight()- diam)
			Vy=Vy*-1;
		
		if (Y<0)
			Vy=Vy*-1;
		
		X+=Vx;		
		Y+=Vy;
	
	}

}
